package main

import (
  "net"
)

type User struct {
  Name string
  Addr string
  // message received from
  C chan string
  // api to send message to server
  conn net.Conn
}

func NewUser(conn net.Conn)*User{
  Addr := conn.RemoteAddr().String()

  user := &User{
    Name: Addr,
    Addr: Addr,
    C: make(chan string),
    conn: conn,
  }

  go user.ListenMessage()

  return user
}

func(this *User) ListenMessage(){
  for {
    msg := <-this.C

    this.conn.Write([]byte(msg + "\n"))
    //something...
  }
}
